/*
 *  $TEAM_NAME Space Trader
 */
package presenters;

import models.Player;
import models.Shipyard;
import models.Ship;

import views.ShipyardPanel;

import java.util.Observer;
import java.util.Observable;

/**
 * Shipyard presenter
 * @author twb
 * @version 1.0
 */
public class ShipyardPresenter extends Presenter<ShipyardPanel> implements Observer {
	/**
	 * field
	 */
	private final Player player;

	/**
	 * field
	 */
	private Shipyard shipyard;
    
	/**
	 * field
	 */
	private Ship ship;
    
    /**
     * Creates a ship yard presenter
     * 
     * @param player The game's player
     * @param view The ship yard panel in the UI
     */
	
	public ShipyardPresenter(Player player, ShipyardPanel view) {
        this.shipyard = player.getLocation().getShipyard(); 
        this.ship = player.getShip();
        this.player = player;

        super.setView(view); 

        player.addObserver(this);
        ship.addObserver(this);
        shipyard.addObserver(this);
    }

	/**
	 * update
	 * @param o
	 * @param arg
	 */
    public void update(Observable o, Object arg) {
        if (o.equals(player)) {
            shipyard = player.getLocation().getShipyard();
            ship = player.getShip();
        }

        view.update();
    }
    
    /**
     * to string
     * @return string
     */
    public String toString() {
		return "";
	}
}
